<template>
  <el-menu
    :default-openeds="openedGroups"
    :default-active="activeIndex"
    :mode="mode"
    router
    @select="handleSelect"
    background-color="#303133"
    text-color="#909399"
    active-text-color="#409EFF"
  >
    <el-menu-item index="/personal">
      <template slot="title">
        <i class="el-icon-user"></i>
        <span>个人信息</span>
      </template>
    </el-menu-item>
    <el-menu-item index="/notify">
      <template slot="title">
        <i class="el-icon-bell"></i>
        <span>提醒</span>
      </template>
    </el-menu-item>
    <el-submenu index="group_1" v-if="adminLevel >= 0">
      <template slot="title">
        <i class="el-icon-finished"></i>
        <span>审核</span>
      </template>
      <el-menu-item index="/verify" v-if="adminLevel >= 0">
        <template slot="title">
          <i class="el-icon-s-check"></i>
          <span>待审核</span>
        </template>
      </el-menu-item>
      <el-menu-item index="/history" v-if="adminLevel >= 0">
        <template slot="title">
          <i class="el-icon-files"></i>
          <span>历史记录</span>
        </template>
      </el-menu-item>
    </el-submenu>
    <el-submenu index="group_2" v-if="adminLevel >= 0">
      <template slot="title">
        <i class="el-icon-edit"></i>
        <span>修改</span>
      </template>
      <el-menu-item index="/modify" v-if="adminLevel >= 0">
        <template slot="title">
          <i class="el-icon-edit"></i>
          <span>信息编辑</span>
        </template>
      </el-menu-item>
      <el-menu-item index="/batch" v-if="adminLevel >= 0">
        <template slot="title">
          <i class="el-icon-receiving"></i>
          <span>批量修改</span>
        </template>
      </el-menu-item>
    </el-submenu>
    <el-submenu index="group_3" v-if="adminLevel >= 0">
      <template slot="title">
        <i class="el-icon-s-data"></i>
        <span>数据I/O</span>
      </template>
      <el-menu-item index="/filter" v-if="adminLevel >= 0">
        <template slot="title">
          <i class="el-icon-s-order"></i>
          <span>数据筛选</span>
        </template>
      </el-menu-item>
      <el-menu-item index="/io" v-if="adminLevel >= 0">
        <template slot="title">
          <i class="el-icon-copy-document"></i>
          <span>导入/导出</span>
        </template>
      </el-menu-item>
    </el-submenu>
    <el-submenu index="group_4" v-if="adminLevel >= 0">
      <template slot="title">
        <i class="el-icon-set-up"></i>
        <span>设置</span>
      </template>
      <el-menu-item index="/qywx" v-if="adminLevel >= 0">
        <template slot="title">
          <i class="el-icon-chat-round"></i>
          <span>企业微信</span>
        </template>
      </el-menu-item>
    </el-submenu>
  </el-menu>
</template>

<script>
export default {
  name: "navigationMenu",
  props: ["mode"],
  components: {},
  data() {
    return {
      openedGroups: ["group_1", "group_2", "group_3", "group_4"],
      activeIndex: "",
    };
  },
  computed: {
    adminLevel() {
      return this.$store.getters.adminLevel;
    },
  },
  methods: {
    handleSelect(params) {
      this.$emit("select", params);
      console.log(params);
    },
  },
  created() {
    if (this.mode == "horizontal") {
      this.openedGroups = [];
    }
  },
};
</script>
